import Pageable = Api.Common.Pageable;
import Page = Api.Common.Page;
import {request} from "@/service/request";

//分页查询流程定义
export function fetchGetProcessDefinition(params?: Pageable) {
  return request<Flow.ProcessDefinition>({
    url: '/workflow/process-definition/list',
    method: 'post',
    data: params
  });
}
//分页查询流程定义
export function fetchGetDeployPage(params?: Pageable) {
  return request<Page<Flow.ProcessDefinition>>({
    url: '/workflow/process-definition/list',
    method: 'post',
    data: params
  });
}

//删除流程定义
export function deleteDeployment(deploymentId: string, processDefinitionId: string) {
  return request<any>({
    url: '/workflow/process-definition/delete/' + deploymentId + '/' + processDefinitionId,
    method: 'delete',
    data: {}
  });
}

//激活或者挂起流程定义
export function fetchUpdateDefinitionState(processDefinitionId: string) {
  return request<any>({
    url: '/workflow/process-definition/update-state/' + processDefinitionId,
    method: 'post',
    data: {}
  });
}

// 流程定义迁移
export function fetchMigrationDefinition(currentProcessDefinitionId: string, fromProcessDefinitionId: string) {
  return request<any>({
    url: '/workflow/process-definition/migration/' + currentProcessDefinitionId + '/' + fromProcessDefinitionId,
    method: 'post',
    data: {}
  });
}

// 获取流程图片
export function fetchGetDefinitionImage(processDefinitionId: string) {
  return request<any>({
    url: '/workflow/process-definition/definition-image/' + processDefinitionId,
    method: 'get',
    data: {}
  });
}
